import java.util.Arrays;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: qian
 * Date: 2022-08-01
 * Time: 9:50
 */
public class TestDemo extends Dog {
    public static void main(String[] args) {
        Dog dog=new Dog();
    }
    public String simplifyPath(String path) {
        StringBuilder pa=new StringBuilder();
        Stack<String> stack=new Stack<>();
        int i=0;
        while(i<path.length()){
            StringBuilder ss=new StringBuilder();
            if(ss.equals("")){
                ss.append(path.charAt(i));
                i++;
            }
            while(i<path.length() && path.charAt(i)=='/'){
                i++;
            }
            while(i<path.length() && path.charAt(i)!='/'){
                ss.append(path.charAt(i));
                i++;
            }
            if(!stack.empty() && ss.equals("/..")){
                stack.pop();
            }else if(ss.equals("/.")){
                continue;
            }else{
                stack.push(ss.reverse().toString());
            }

        }
        if(!stack.empty() && stack.peek().equals("/")){
            stack.pop();
        }
        while(!stack.empty()){
            pa.append(stack.pop());
        }
        return pa.reverse().toString();
    }

    private static boolean isPrime1(int n) {
        if(n<2)
            return false;
        for (int i = 2; i <n ; i++) {
            if(n%i==0)
                return false;
        }
        return true;
    }
    public static void main17(String[] args) {
        Scanner  sc = new Scanner(System.in);
        int a = sc.nextInt();
        System.out.println("输入需要判断的数");
        for(int i =2;i <a;i++){
            if(a %i ==0){
                System.out.println("不是素数");
            }else if(i ==a){
                System.out.println("是素数");
            }

        }

    }
    public static void main16(String[] args) {
        //打印 1 - 100 之间所有的素数
        int i;
        for(int a=1;a<=100;a++)
        {
            for(i=2;i<a;i++){

                if(a%i ==0){
                    break;
                }
            }
            if(i==a){
                System.out.println(a);
            }
        }

    }
    public static void main14(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int i=1;
        int cnt=0;
        while(i<=32){
            if((n&1)==1){
                cnt++;
            }
            n>>=1;
            i++;
        }
        System.out.println(cnt);
    }
    public static void reOrderArray(int [] array) {
        int i=0;
        while(i<array.length){
            if(array[i]%2==1){
                i++;
            }else{
                int j=i;
                while(j<array.length&&array[j]%2==0){
                    j++;
                }
                if(j== array.length){
                    break;
                }
                int temp=array[j];
                while(j>i){
                    array[j]=array[j-1];
                    j--;
                }
                array[i]=temp;
            }
        }
    }

    public static void main13(String[] args) {
        int[] arr={1,2,3,4,5};
        reOrderArray(arr);
        System.out.println(arr);
    }
    public static void main12(String[] args){
        Scanner sc=new Scanner(System.in);
        String s1="7+IE.";
        String s2="7_This_is_a_test.";
        int i=0;
        StringBuilder sb=new StringBuilder();
        while(i<s2.length()){
            char ch=s2.charAt(i);
            if(s1.contains((ch+"").toUpperCase())||s1.contains(ch+"")){
                i++;
            }else if(s1.contains("+")&&(ch>='A'&&ch<='Z')){
                i++;
            }else{
                sb.append(ch+"");
                i++;
            }
        }
        System.out.println(sb.toString());
    }
    public static void main11(String[] args) {
        int[][] arr4 = {{1,2,3,4,5},{1,128,3,4,5,2,23}};

        int ret = 0;
        for (int i = 0; i < arr4.length ; i++) {
            for (int j = 0; j < arr4[i].length ; j++) {
                ret ^= arr4[i][j];
            }
        }
//    此时得到ret的数值    接下来就要进行剥离
        int pos = 0;
        for (int i = 0; i < 32 ; i++) {
            if(((ret>>i) & 1) == 1 )
            {
                pos=i;
                break;
            }

        }
//    此时得到pos的数值  ，我们就知道哪里有1
        int numx = 0;
        int numy = 0;
        for (int i = 0; i < arr4.length; i++) {
            for (int j = 0; j < arr4[i].length ; j++) {

                if(((arr4[i][j] >> pos) & 1) == 1)
                {
                    numx ^= arr4[i][j];
                } else if (((arr4[i][j] >> pos) & 1) == 0) {
                    numy ^= arr4[i][j];

                }
            }

        }
        System.out.println(numx + "   " + numy);
    }
    public static int calc(String s){
        Stack<Double> stack=new Stack<>();
        double num=0;
        int i;
        char op='+';
        for(i=0;i<s.length();i++){
            if(s.charAt(i)>='0'&&s.charAt(i)<='9'){
                num=num*10+s.charAt(i)-'0';
                if(i!=s.length()-1){
                    continue;
                }
            }
            switch(op){
                case '+':
                    stack.push(num);
                    break;
                case '-':
                    stack.push(-1*num);
                    break;
                case '*':
                    double temp=stack.pop();
                    stack.push(temp*num);
                    break;
                case '/':
                    temp=stack.pop();
                    stack.push(temp/num);
                    break;
            }
            num=0;
            op=s.charAt(i);
        }
        double sum=0;
        while(!stack.isEmpty()){
            sum+=stack.pop();
        }
        return (int)sum;
    }
    public static void main10(String[] args){
        //Scanner sc=new Scanner(System.in);
        String s="1-10/4+6+6-4-9-6/4+7";
        System.out.println(calc(s));
//        while(sc.hasNextLine()){
//            String s=sc.nextLine();
//            System.out.println(calc(s));
//        }
    }
    public static void main9(String[] args) {
        int[][] arr4 = new int[2][];
        arr4[0] = new int[]{1,2,3,4};
        arr4[1] = new int[]{4,3,2,1,7};
        int ret = 0;       //初始化一个数值，0与任何数异或都是任何数
        for (int i = 0; i < arr4.length ; i++) {
            for (int j = 0; j < arr4[i].length  ; j++) {
                ret ^=  arr4[i][j];

            }

        }
        System.out.println("您的出现一次的数值" + ret );

    }
    public static void main8(String[] args) {
        int count = 0;
        Scanner scan = new Scanner(System.in);
        int num =  scan.nextInt();
        while(num != 0 ){
            if((num & 1) == 1){
                count++;
            }
            num >>= 1;
        }
        System.out.println(count);
    }
    public static void main7(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int i = 0;
        for (i = 2; i <= num; i++) {

            if(num % i == 0 && i != num){
                System.out.println( num + "不是素数");
                break;
            }
        }
        if(i > num/2){
            System.out.println(num + "素数");
        }
    }
    public static void main6(String[] args) {
        Scanner reader =new Scanner(System.in);
        int num;
        num=reader.nextInt();
        //int a = 20;
        int i = 0;
        for (i = 2; i < num; i++) {
            if (num % i == 0) {
                System.out.println("不是素数");
                break;
            }else{
                System.out.println("是素数");
                break;
            }
        }
    }
    public static int fac(int n) {
        if(n == 1) {
            return n;
        }
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += (i*fac(i-1));
        }
        return sum;
    }
    public static void main5(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ret = fac(n);
        System.out.println(ret);
    }
    public static void main4(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int num=scanner.nextInt();
        System.out.print("奇数位：");
        for (int i = num; i > 0; i/=4) {
            System.out.print(i%2+" ");
        }
        System.out.println();
        System.out.print ("偶数位：");
        for (int i = num/2; i>0; i/=4) {
            System.out.print(i%2+" ");
        }
    }
    public static void main3(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int count = 0;
        int i=a;
        for (i=a; i>0; i /= 2) {
            if (i % 2 == 1) {
                count++;
            }
        }
        if(a==-1){
            count=32;
        }
        System.out.println(count);
    }
    public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int flag=0;
        int i=0;
        for(i=2;i<a;i++){
            if(a%i==0) {
                flag=1;
            }
        }
        if(flag==1) {
            System.out.println("不是素数");
        } else{
            System.out.println("是素数");
        }
    }
    public static boolean isPrime(int number){
        if(number <= 1) return false; //number需要是比1大的正整数
        int i = 0;
        for(i = 2; i <= (int)Math.sqrt(number); i++){ //当number是2和3时不进循环体，直接返回true
            if(number % i == 0){
                return false;
            }
        }
        return true;
    }
    public static void main1(String[] args) {
        int number = 0;
        System.out.print("请输入一个数字：");
        number = new Scanner(System.in).nextInt(); //获取键盘输入数字
        boolean ret = isPrime(number);
        if(ret){
            System.out.println(number + " is a prime number.");
        }else{
            System.out.println(number + " is not a prime number.");
        }
    }
}
